<template>
  <div class="recommend-info">
     <div class="goodItem" v-for="(item,index) in recommends" :key="index">
      <img :src="item.image" alt="" @load="loadImg"  @click="itemClick(item.item_id)">
      <div class="goods-info">
        <p>{{item.title}}</p>
        <span class="price">{{item.price}}</span>
        <span class="collect">{{item.cfav}}</span>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name:"DetailRecommendInfo",
    props:{
      recommends:{
        type:Array,
        default(){
          return []
        }
      }
    },
   methods: {
     loadImg(){
       this.$emit('itemloadImg')
     },
     itemClick(iid){
       this.$router.push(`/detail/${iid}`,()=>{})
     }
   },
  }
</script>

<style scoped>
  .recommend-info {
     width: 100%;
     display: flex;
     flex-wrap: wrap;
     justify-content: space-around;
     padding: 10px 0;
     border-bottom: 5px solid #f2f5f8;
   }

   .goodItem {
     width: 48%;
     padding-bottom: 60px;
     position: relative;
     overflow: hidden;
     margin-bottom: 5px;
   }

   .goodItem img {
     width: 100%;
     border-radius: 5px;
   }
   .goods-info {
     width: 100%;
     position: absolute;
     bottom: 0;
     font-size: 15px;
     text-align: center;
   }

   .goods-info p {
     text-overflow: -o-ellipsis-lastline;
     overflow: hidden;
     text-overflow: ellipsis;
     display: -webkit-box;
     -webkit-line-clamp: 2;
     line-clamp: 2;
     -webkit-box-orient: vertical;
     
     margin-bottom: 3px;
   }

   .goods-info .price {
    color: var(--color-high-text);
   }

   .goods-info .collect {
    position: relative;
    padding-left: 25px;
    }

  .goods-info .collect::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 0px;
    width: 15px;
    height: 15px;
    background: url("~assets/images/common/collect.svg") 0 0/15px 15px;
  }

  .isCollect {
    color: red;
  }
</style>